<!-- 表格菜单组件 -->
<template>
  <div class="menu">
    <div class="title">{{ title }}</div>
    <a-menu
      style="width: 150px;border-right: none;"
      mode="inline"
      :inlineIndent="0"
      :defaultSelectedKeys="getDefaultSelectedKeys"
      @click="handleClick"
    >
      <a-menu-item v-for="item in menuList" :key="item.key">
        <div style="width:100%;text-align: center;">{{ item.name }}</div>
      </a-menu-item>
    </a-menu>
  </div>
</template>

<script>
export default {
  props: ['title', 'menuList', 'selectKey'],
  components: {},
  data() {
    return {}
  },
  computed: {
    getDefaultSelectedKeys() {
      let menu = this.menuList[0] || {}
      return this.selectKey ? [this.selectKey] : [menu.key]
    }
  },
  watch: {},
  methods: {
    handleClick(e) {
      this.$emit('change', e.key)
    }
  },
  created() {},
  mounted() {}
}
</script>
<style scoped lang="less">
.menu {
  margin-right: 10px;
  background: #fff;
  .title {
    font-size: 16px;
    padding: 10px 10px 5px 10px;
    font-weight: bold;
  }
}
</style>
